'use strict';
const Koa = require('koa');
var Mock = require('mockjs')
const KoaRouter = require('koa-router');

const app = new Koa();
const router = new KoaRouter();

app.use(router['routes']());

// 钱包 —— 获取账户开户信息
router.post('/pc/V1/accountInfo/getPayAccountInfo', function (ctx, next) {
    console.log('钱包 —— 获取账户开户信息')

    ctx.body = {
	    "status": 0,
	    "data": [
	         {
	            "userId": "F0935E4CD5920AA6C7C996A5EE53A70F",
	            "storeId": "b0463324f86d37504d85be3196c200be",
	            "payMechanism": "04",
	            "accountType": "0",
	            "merchantCode": "898513248218180",
	            "merchantName": "雅安市名山区名发商行",
	            "merchantAbbr": "雅安市名山区名发商行",
	            "account": "898513248218180",
	            "name": "雅安市名山区名发商行",
	            "mechanism": "中国农业银行",
	            "mechanismName": "中国农业银行",
	            "mechanismAddress": null,
	            "createPerson": "F0935E4CD5920AA6C7C996A5EE53A70F",
	            "phone": null,
	            "remarks": null,
	            "status": "0"
	        },
	        {
	            "userId": "F0935E4CD5920AA6C7C996A5EE53A70F",
	            "storeId": "b0463324f86d37504d85be3196c200be",
	            "payMechanism": "04",
	            "accountType": "1",
	            "merchantCode": "898513248218180",
	            "merchantName": "雅安市名山区名发商行",
	            "merchantAbbr": "雅安市名山区名发商行",
	            "account": "898513248218180",
	            "name": "雅安市名山区名发商行",
	            "mechanism": "中国农业银行",
	            "mechanismName": "中国农业银行",
	            "mechanismAddress": null,
	            "createPerson": "F0935E4CD5920AA6C7C996A5EE53A70F",
	            "phone": null,
	            "remarks": null,
	            "status": "0"
	        }
	    ],
	    "msg": "success"
	}
});

// 钱包 —— 我的银行卡列表
router.post('/pc/V1/wallet/getBindCardList', function (ctx, next) {
    console.log('钱包 —— 我的银行卡列表')
    
    ctx.body = {
	    "status": 0,
	    "data": [{
            "id": "d1e7700623604f7a89db9dd7947bd466",
            "bindId": "PR201803191556178258",
            "userId": "F0935E4CD5920AA6C7C996A5EE53A70F",
            "bankCardNo": "2701",
            "cardType": "3",
            "bankId": "ABC",
            "bankName": "中国农业银行",
            "cardholderName": "袁世凯",
            "idcardNo": "12345687925413698",
            "mobile": "13730871900",
            "bindStatus": "1",
            "createPerson": "2132131232131",
            "createTimestamp": 1521446192000,
            "updatePerson": null,
            "updateTimestamp": null,
            "logicDeleteFlg": "0",
            "userBusiId": "P2018031214170000000000000002665",
            "fullBankCardNo": "",
            "payMechanism": "04",
            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/ABC.png"
        },
        {
            "id": "e908e512288c4bf4911e46647085937f",
            "bindId": "PR201803261403224425",
            "userId": "F0935E4CD5920AA6C7C996A5EE53A70F",
            "bankCardNo": "4265",
            "cardType": "1",
            "bankId": "CCB",
            "bankName": "中国建设银行",
            "cardholderName": "陈懋",
            "idcardNo": "511011199211058757",
            "mobile": "13730871902",
            "bindStatus": "1",
            "createPerson": "2132131232131",
            "createTimestamp": 1522044220000,
            "updatePerson": null,
            "updateTimestamp": null,
            "logicDeleteFlg": "0",
            "userBusiId": "P2018032614080500000000000002694",
            "fullBankCardNo": "",
            "payMechanism": "04",
            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/CCB.png"
        },
        {
            "id": "7aa41beda2de46c29560fb5a67cff786",
            "bindId": "PR201803191545189526",
            "userId": "F0935E4CD5920AA6C7C996A5EE53A70F",
            "bankCardNo": "2501",
            "cardType": "1",
            "bankId": "CCB",
            "bankName": "中国建设银行",
            "cardholderName": "袁世凯",
            "idcardNo": "12345687925413698",
            "mobile": "13730871900",
            "bindStatus": "1",
            "createPerson": "2132131232131",
            "createTimestamp": 1521445531000,
            "updatePerson": null,
            "updateTimestamp": null,
            "logicDeleteFlg": "0",
            "userBusiId": "P2018031915500200000000000002682",
            "fullBankCardNo": "",
            "payMechanism": "04",
            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/CCB.png"
        }],
	    "msg": "查询成功"
	}
});

// 获取账户余额
router.post('/pc/V1/wallet/getBalance', function (ctx, next) {
    console.log('钱包 —— 我的银行余额')
    var data = Mock.mock({
	    "status": 0,
	    "data": {
	        "balanceDetail": [
	        	{"balance":"52234900","acc_state":"1","acc_type":"209","avl_bal":"276234"},
	        	{"balance":"59437464","acc_state":"1","acc_type":"208","avl_bal":"180233"},
	        ],
	        "withDrawFee": 70,
	        "code": "00",
	        "msg": "查询余额成功"
	    },
	    "msg": "获取余额成功"
	})
    ctx.body = data
});



// 是否设置了支付密码
router.get('/pc/V1/paymentPassword/havePassword', function (ctx, next) {
    console.log('钱包 —— 是否设置了支付密码')
    var data = Mock.mock({
	    "status": 0,
	    "data": false,
	    "msg": "用户支付密码不存在"
	})
    ctx.body = data
});

// 校验支付密码
router.post('/pc/V1/paymentPassword/passwordValidate', function (ctx, next) {
    console.log('钱包 —— 校验支付密码')
    var data = Mock.mock({
	    "status": 0,
	    "data": true,
	    "msg": "密码正确"
	})
    ctx.body = data
});
// 确认转账
router.post('/pc/V1/wallet/transfer', function (ctx, next) {
    console.log('钱包 —— 确认转账')
    var data = Mock.mock({
	    "status": 2,
	    "data": {
	    },
	    "msg": "金额发生变化."
	})
    ctx.body = data
});


// 确认提现
router.post('/pc/V1/wallet/withDraw', function (ctx, next) {
    console.log('钱包 —— 确认提现')
    var data = Mock.mock({
	    "status": 0,
	    "data": { },
	    "msg": "余额不足"
	})
    ctx.body = data
});


// 获取真实姓名
router.get('/pc/V1/wallet/getLawyerNameAndId', function (ctx, next) {
    console.log('钱包 —— 获取真实姓名')
    var data = Mock.mock({
	    "status": 0,
	    "data": {
	        "idCard": "513101196512290016",
	        "name": "Carinbe"
	    },
	    "msg": "获取法人姓名和身份证号成功"
	})
    ctx.body = data
});


// 获取自动提现开关信息
router.post('/pc/V1/wallet/getAutoWithDrawConfig', function (ctx, next) {
    console.log('钱包 —— 获取自动提现开关信息')
    var data = Mock.mock({
	    "status": 0,
	    "data": {
	        "autoSwitch|1": 1,
	        "publicCardId": "511025451541225874",
	        "privateCardId": "621886610008635487"
	    },
	    "msg": "查询成功"
	})
    ctx.body = data
});

// 保存自动提现开关设置
router.post('/pc/V1/wallet/autoWithDrawConfig', function (ctx, next) {
    console.log('钱包 —— 保存自动提现开关设置')
    var data = Mock.mock({
	    "status": 0,
	    "data|1": true,
	    "msg": "自动提现设置成功"
	})
    ctx.body = data
});

// 绑卡下单第一步
router.post('/pc/V1/wallet/bindOrder', function (ctx, next) {
    console.log('钱包 —— 绑卡下单')
	    var data = Mock.mock({
	    "status|0-1": 1,
	    "data": {
	        "danluOrderId":"123123212312",
	        "umpTradeNo":"12321321321321"
	    },
	    "msg": "绑卡下单失败"
	})
    ctx.body = data
});

// 绑卡下单确认
router.post('/pc/V1/wallet/bindConfirm', function (ctx, next) {
    console.log('钱包 —— 绑卡下单')
	    var data = Mock.mock({
	    "status|0-1": 1,
	    "data": null,
	    "msg": "绑卡下单失败"
	})
    ctx.body = data
});


// 获取银行卡所属银行
router.get('/pc/V1/wallet/queryUmpHomeBank', function (ctx, next) {
    console.log('钱包 —— 获取银行卡所属银行')
	    var data = Mock.mock({
		    "status": 0,
		    "data": [
		        {
		            "bankName": "招商银行",
		            "cardType": "1",
		            "bankId": "CMB"
		        }
		    ],
		    "msg": "查询卡号归属银行成功"
		})
    ctx.body = data
});

// 获取支持银行卡列表
router.post('/pc/V1/wallet/bindBankList', function (ctx, next) {
    console.log('钱包 —— 获取支持银行卡列表')
	    var data = Mock.mock({
		    "status": 0,
		    "data": [
		        {
		            "id": "60",
		            "bankId": "ICBC",
		            "bankName": "中国工商银行",
		            "cardType": "1",
		            "isSupport": "0",
		            "createPerson": "sylar",
		            "createTimestamp": 1521016017000,
		            "updatePerson": null,
		            "updateTimestamp": null,
		            "logicDeleteFlg": "0",
		            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/ICBC.png"
		        },
		        {
		            "id": "71",
		            "bankId": "SPAB",
		            "bankName": "平安银行",
		            "cardType": "1",
		            "isSupport": "0",
		            "createPerson": "sylar",
		            "createTimestamp": 1521016017000,
		            "updatePerson": null,
		            "updateTimestamp": null,
		            "logicDeleteFlg": "0",
		            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/SPAB.png"
		        },
		        {
		            "id": "70",
		            "bankId": "CMB",
		            "bankName": "招商银行",
		            "cardType": "1",
		            "isSupport": "0",
		            "createPerson": "sylar",
		            "createTimestamp": 1521016017000,
		            "updatePerson": null,
		            "updateTimestamp": null,
		            "logicDeleteFlg": "0",
		            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/CMB.png"
		        },
		        {
		            "id": "69",
		            "bankId": "CITIC",
		            "bankName": "中信银行",
		            "cardType": "1",
		            "isSupport": "0",
		            "createPerson": "sylar",
		            "createTimestamp": 1521016017000,
		            "updatePerson": null,
		            "updateTimestamp": null,
		            "logicDeleteFlg": "0",
		            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/CITIC.png"
		        },
		        {
		            "id": "68",
		            "bankId": "GDB",
		            "bankName": "广发银行",
		            "cardType": "1",
		            "isSupport": "0",
		            "createPerson": "sylar",
		            "createTimestamp": 1521016017000,
		            "updatePerson": null,
		            "updateTimestamp": null,
		            "logicDeleteFlg": "0",
		            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/GDB.png"
		        },
		        {
		            "id": "67",
		            "bankId": "SPDB",
		            "bankName": "浦东发展银行",
		            "cardType": "1",
		            "isSupport": "0",
		            "createPerson": "sylar",
		            "createTimestamp": 1521016017000,
		            "updatePerson": null,
		            "updateTimestamp": null,
		            "logicDeleteFlg": "0",
		            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/SPDB.png"
		        },
		        {
		            "id": "66",
		            "bankId": "CMBC",
		            "bankName": "中国民生银行",
		            "cardType": "1",
		            "isSupport": "0",
		            "createPerson": "sylar",
		            "createTimestamp": 1521016017000,
		            "updatePerson": null,
		            "updateTimestamp": null,
		            "logicDeleteFlg": "0",
		            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/CMBC.png"
		        },
		        {
		            "id": "65",
		            "bankId": "CIB",
		            "bankName": "兴业银行",
		            "cardType": "1",
		            "isSupport": "0",
		            "createPerson": "sylar",
		            "createTimestamp": 1521016017000,
		            "updatePerson": null,
		            "updateTimestamp": null,
		            "logicDeleteFlg": "0",
		            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/CIB.png"
		        },
		        {
		            "id": "64",
		            "bankId": "CEB",
		            "bankName": "光大银行",
		            "cardType": "1",
		            "isSupport": "0",
		            "createPerson": "sylar",
		            "createTimestamp": 1521016017000,
		            "updatePerson": null,
		            "updateTimestamp": null,
		            "logicDeleteFlg": "0",
		            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/CEB.png"
		        },
		        {
		            "id": "63",
		            "bankId": "BOC",
		            "bankName": "中国银行",
		            "cardType": "1",
		            "isSupport": "0",
		            "createPerson": "sylar",
		            "createTimestamp": 1521016017000,
		            "updatePerson": null,
		            "updateTimestamp": null,
		            "logicDeleteFlg": "0",
		            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/BOC.png"
		        },
		        {
		            "id": "62",
		            "bankId": "CCB",
		            "bankName": "中国建设银行",
		            "cardType": "1",
		            "isSupport": "0",
		            "createPerson": "sylar",
		            "createTimestamp": 1521016017000,
		            "updatePerson": null,
		            "updateTimestamp": null,
		            "logicDeleteFlg": "0",
		            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/CCB.png"
		        },
		        {
		            "id": "61",
		            "bankId": "ABC",
		            "bankName": "中国农业银行",
		            "cardType": "1",
		            "isSupport": "0",
		            "createPerson": "sylar",
		            "createTimestamp": 1521016017000,
		            "updatePerson": null,
		            "updateTimestamp": null,
		            "logicDeleteFlg": "0",
		            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/ABC.png"
		        },
		        {
		            "id": "72",
		            "bankId": "COMM",
		            "bankName": "交通银行",
		            "cardType": "1",
		            "isSupport": "0",
		            "createPerson": "sylar",
		            "createTimestamp": 1521016017000,
		            "updatePerson": null,
		            "updateTimestamp": null,
		            "logicDeleteFlg": "0",
		            "bankIconUrl": "http://asset.danlu.com/mobile/images/bankico/COMM.png"
		        }
		    ],
		    "msg": "获取银行列表成功"
		})
    ctx.body = data
});

// 获取银行卡所属银行
router.post('/pc/V1/wallet/tradeQuery', function (ctx, next) {
    console.log('钱包 —— 获取银行卡所属银行')
	    var data = Mock.mock({
		    "data_list": [
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "6",
		            "mer_date": "20180408",
		            "acc_check_date": "20180408",
		            "order_id": "PR201804081400102858",
		            "trans_type": "01"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "5",
		            "mer_date": "20180408",
		            "acc_check_date": "20180408",
		            "order_id": "PR201804081359015754",
		            "trans_type": "02"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "4",
		            "mer_date": "20180408",
		            "acc_check_date": "20180408",
		            "order_id": "PR201804081358041088",
		            "trans_type": "03"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "3",
		            "mer_date": "20180404",
		            "acc_check_date": "20180404",
		            "order_id": "PR201804041703094537",
		            "trans_type": "04"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "2",
		            "mer_date": "20180404",
		            "acc_check_date": "20160404",
		            "order_id": "PR201804041654318977",
		            "trans_type": "05"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "1",
		            "mer_date": "20180330",
		            "acc_check_date": "20160330",
		            "order_id": "PR201803301819017848",
		            "trans_type": "06"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "0",
		            "mer_date": "",
		            "acc_check_date": "20170330",
		            "order_id": "",
		            "trans_type": "02"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "1",
		            "mer_date": "20180329",
		            "acc_check_date": "20170329",
		            "order_id": "PR201803291203281414",
		            "trans_type": "03"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "5",
		            "mer_date": "20180408",
		            "acc_check_date": "20180408",
		            "order_id": "PR201804081359015754",
		            "trans_type": "02"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "4",
		            "mer_date": "20180408",
		            "acc_check_date": "20180408",
		            "order_id": "PR201804081358041088",
		            "trans_type": "03"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "3",
		            "mer_date": "20180404",
		            "acc_check_date": "20180404",
		            "order_id": "PR201804041703094537",
		            "trans_type": "04"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "2",
		            "mer_date": "20180404",
		            "acc_check_date": "20160404",
		            "order_id": "PR201804041654318977",
		            "trans_type": "05"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "1",
		            "mer_date": "20180330",
		            "acc_check_date": "20160330",
		            "order_id": "PR201803301819017848",
		            "trans_type": "06"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "0",
		            "mer_date": "",
		            "acc_check_date": "20170330",
		            "order_id": "",
		            "trans_type": "02"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "1",
		            "mer_date": "20180329",
		            "acc_check_date": "20170329",
		            "order_id": "PR201803291203281414",
		            "trans_type": "03"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "5",
		            "mer_date": "20180408",
		            "acc_check_date": "20180408",
		            "order_id": "PR201804081359015754",
		            "trans_type": "02"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "4",
		            "mer_date": "20180408",
		            "acc_check_date": "20180408",
		            "order_id": "PR201804081358041088",
		            "trans_type": "03"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "3",
		            "mer_date": "20180404",
		            "acc_check_date": "20180404",
		            "order_id": "PR201804041703094537",
		            "trans_type": "04"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "2",
		            "mer_date": "20180404",
		            "acc_check_date": "20160404",
		            "order_id": "PR201804041654318977",
		            "trans_type": "05"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "1",
		            "mer_date": "20180330",
		            "acc_check_date": "20160330",
		            "order_id": "PR201803301819017848",
		            "trans_type": "06"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "0",
		            "mer_date": "",
		            "acc_check_date": "20170330",
		            "order_id": "",
		            "trans_type": "02"
		        },
		        {
		            "amount": "1",
		            "trans_state": "1",
		            "balance": "1",
		            "mer_date": "20180329",
		            "acc_check_date": "20170329",
		            "order_id": "PR201803291203281414",
		            "trans_type": "03"
		        }
		    ],
		    "total": 210,
		    "index": 1,
		    "size": 3,
		    "sort": "",
		    "status": 0,
		    "msg": "账单查询成功"
		})
    ctx.body = data
});


app.listen(8000);
console.log('mock is start at port 8000');
